package routes

import (
	"invitation/internal/application"
	"invitation/internal/http/endpoints/admin"
	"invitation/internal/http/middleware"

	"github.com/gofiber/fiber/v2"
)

func RegisterAdminRoutes(app *fiber.App, application *application.Application, re *middleware.RequestExtractor) {
	gameCreateChain := []fiber.Handler{
		re.SetGamePayload(),
		admin.CreateGameEndpoint(application),
	}
	app.Post("/admin/game/create", gameCreateChain...)
	gameUpdateChain := []fiber.Handler{
		re.SetGamePayload(),
		admin.UpdateGameEndpoint(application),
	}
	app.Post("/admin/game/update", gameUpdateChain...)

	app.Get("/admin/game/list", admin.GameListAllEndpoint(application))

	gameDeleteChain := []fiber.Handler{
		re.SetGamePayload(),
		admin.DeleteGameEndpoint(application),
	}
	app.Post("/admin/game/delete", gameDeleteChain...)

	teacherCreateChain := []fiber.Handler{
		re.SetTeacherPayload(),
		admin.CreateTeacherEndpoint(application),
	}
	app.Post("/admin/teacher/create", teacherCreateChain...)

	teacherUpdateChain := []fiber.Handler{
		re.SetTeacherPayload(),
		admin.UpdateTeacherEndpoint(application),
	}
	app.Post("/admin/teacher/update", teacherUpdateChain...)

	app.Get("/admin/teacher/list", admin.TeacherListAllEndpoint(application))

	teacherDeleteChain := []fiber.Handler{
		re.SetTeacherPayload(),
		admin.DeleteTeacherEndpoint(application),
	}
	app.Post("/admin/teacher/delete", teacherDeleteChain...)
}
